/*cnpm install express --save*/
var express=require('express');//导入express(http框架)
var app=new express();//实例化express
var url=require('url')

var logger=function (req,res,next) {
     var urlObj=url.parse(req.url,true);
    console.log("the url is :"+urlObj.pathname);

    next();
}

app.use(logger);

app.get('/',function (req,res) {
    res.send('root');
})

app.get('/login',function (req,res) {
    res.send('login');
})

var server = app.listen(3000,'localhost',function () {

    var host = server.address().address;
    var port = server.address().port;

    console.log("这个服务的访问地址是 http://%s:%s",host, port);
})// 通过监听3000,建立一个服务器
